/*     */ package com.newcrm.db;
/*     */ 
/*     */ import com.newcrm.exception.DBException;
/*     */ import java.sql.Connection;
/*     */ import java.sql.SQLException;
/*     */ import java.util.Map;
/*     */ import org.apache.commons.dbutils.DbUtils;
/*     */ import org.apache.commons.dbutils.MyMapHandler;
/*     */ import org.apache.commons.dbutils.QueryRunner;
/*     */ import org.apache.log4j.Logger;
/*     */ 
/*     */ public class CompanySMSManager
/*     */ {
/*  16 */   private static Logger logger = Logger.getLogger(CompanySMSManager.class
/*  17 */     .getName());
/*     */ 
/*     */   public Map<String, Object> getCompanySMSSetting(int companyId)
/*     */     throws DBException, SQLException
/*     */   {
/*  29 */     Connection conn = ConnectionManager.getInstance().getConnection();
/*  30 */     if (conn == null) {
/*  31 */       throw new DBException();
/*     */     }
/*     */ 
/*  34 */     QueryRunner runner = new QueryRunner();
/*     */     try {
/*  36 */       return (Map)runner.query(conn, "SELECT * FROM T_Company_SMS_Info WHERE CompanyId = ?", 
/*  37 */         new MyMapHandler(), new Object[] { Integer.valueOf(companyId) });
/*     */     } finally {
/*     */       try {
/*  40 */         DbUtils.close(conn);
/*     */       } catch (SQLException e) {
/*  42 */         logger.warn("close conn failed", e);
/*     */       }
/*     */     }
/*     */   }
/*     */ 
/*     */   public int add(int companyId, String serialNumber, String serialPassword, String spNumber, String signature)
/*     */     throws SQLException, DBException
/*     */   {
/*  61 */     Connection conn = ConnectionManager.getInstance().getConnection();
/*  62 */     if (conn == null) {
/*  63 */       throw new DBException();
/*     */     }
/*  65 */     QueryRunner runner = new QueryRunner();
/*     */     try
/*     */     {
/*  68 */       return runner.update(conn, "INSERT INTO T_Company_SMS_Info (CompanyId,SerialNumber,SerialPassword,SpNumber,Signature,CreateDate,UpdateDate) VALUES (?,?,?,?,?,NOW(),NOW())", new Object[] { Integer.valueOf(companyId), 
/*  69 */         serialNumber, serialPassword, spNumber, signature });
/*     */     } finally {
/*     */       try {
/*  72 */         DbUtils.close(conn);
/*     */       } catch (SQLException e) {
/*  74 */         logger.warn("close conn failed", e);
/*     */       }
/*     */     }
/*     */   }
/*     */ 
/*     */   public int update(int companyId, String serialNumber, String serialPassword, String spNumber, String signature)
/*     */     throws SQLException, DBException
/*     */   {
/*  94 */     Connection conn = ConnectionManager.getInstance().getConnection();
/*  95 */     if (conn == null) {
/*  96 */       throw new DBException();
/*     */     }
/*  98 */     QueryRunner runner = new QueryRunner();
/*     */     try
/*     */     {
/* 101 */       return runner.update(conn, "UPDATE T_Company_SMS_Info SET SerialNumber = ?, SerialPassword = ?, SpNumber = ?, Signature = ?, UpdateDate = NOW() WHERE CompanyId = ?", new Object[] { 
/* 102 */         serialNumber, serialPassword, spNumber, signature, 
/* 103 */         Integer.valueOf(companyId) });
/*     */     } finally {
/*     */       try {
/* 106 */         DbUtils.close(conn);
/*     */       } catch (SQLException e) {
/* 108 */         logger.warn("close conn failed", e);
/*     */       }
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\E\referenceProject\CRM参考\qikebao\WEB-INF\lib\qikebao.jar
 * Qualified Name:     com.newcrm.db.CompanySMSManager
 * JD-Core Version:    0.6.1
 */